import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MatVO, MatForm, MatQuery } from '@/api/wmscloud/mat/types';

/**
 * 查询物料主数据列表
 * @param query
 * @returns {*}
 */

export const listMat = (query?: MatQuery): AxiosPromise<MatVO[]> => {
  return request({
    url: '/wmsCloud/mat/list',
    method: 'get',
    params: query
  });
};
/**
 * 查询所有物料单位
 * @returns {*}
 */

export const listAllMat = (): AxiosPromise<MatVO[]> => {
  return request({
    url: '/wmsCloud/mat/listAllMat',
    method: 'get'
  });
};
/**
 * 查询物料主数据详细
 * @param matId
 */
export const getMat = (matId: string | number): AxiosPromise<MatVO> => {
  return request({
    url: '/wmsCloud/mat/' + matId,
    method: 'get'
  });
};

/**
 * 新增物料主数据
 * @param data
 */
export const addMat = (data: MatForm) => {
  return request({
    url: '/wmsCloud/mat',
    method: 'post',
    data: data
  });
};

/**
 * 修改物料主数据
 * @param data
 */
export const updateMat = (data: MatForm) => {
  return request({
    url: '/wmsCloud/mat',
    method: 'put',
    data: data
  });
};

/**
 * 删除物料主数据
 * @param matId
 */
export const delMat = (matId: string | number | Array<string | number>) => {
  return request({
    url: '/wmsCloud/mat/' + matId,
    method: 'delete'
  });
};
